package com.ruoyi.system.outto.goods.impl;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.inter.mapper.ArtRecMapper;
import com.ruoyi.system.model.domain.ArtRec;
import com.ruoyi.system.model.domain.GameAttribute;
import com.ruoyi.system.model.domain.GoodsInfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.model.mapper.SuprAuthMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.dto.yx7881.utils.HttpUtil;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.goods.NEWMAITAOAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/5 16:19
 */
@Slf4j
@Service
public class NEWMAITAOAPIImpl implements NEWMAITAOAPI {

    @Resource
    private InfoImgMapper infoImgMapper;
    @Resource
    private SuprAuthMapper suprAuthMapper;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;
    @Resource
    private GameAttributeMapper gameAttributeMapper;
    @Resource
    private ArtRecMapper artRecMapper;
    @Resource
    private CommonApi commonApi;
    @Value("${desc.title}")
    private String descTitle;
    private SalePartner salePartner;

    @Override
    public AjaxResult addGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(salePartner.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        if (CollectionUtils.isNotEmpty(artRecs)) {
            return editGame(goodsInfoAndAttrValueDto,salePartner);
        }
        this.salePartner = salePartner;
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, "add", salePartner);
        Map<String, Object> result = new HashMap<>();
        Map<String, String> header = new HashMap<>();
        header.put("appkey",salePartner.getSaleKey());
        header.put("appsecret",salePartner.getOther());
        String response = null;
        try {
            response = HttpUtils.sendPost(salePartner.getTwoOther(),JSONObject.toJSONString(params), header);
        } catch (IOException e) {
            e.printStackTrace();
        }
        log.info("麦淘添加接口请求参数={}", JSONObject.toJSONString(params));
        log.info("麦淘添加接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"200".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                String data = resultJson.getString("data");
                String id = JSONObject.parseObject(data).getString("id");
                System.out.println(id);
                result.put("code", 200);

                if (CollectionUtils.isNotEmpty(artRecs)) {
                    artRecs.get(0).setOutid(id);
                    artRecMapper.updateArtRec(artRecs.get(0));
                } else {
                    artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
                    artRecreq.setCreateId(goodsInfoAndAttrValueDto.getCreateId());
                    artRecreq.setType(LCConstant.interAdd);
                    artRecreq.setConfig(salePartner.getId());
                    artRecreq.setSaleCode(salePartner.getSaleName());
                    artRecreq.setOutid(id);
                    artRecMapper.insertArtRec(artRecreq);
                }
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "添加失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, "update", salePartner);
        Map<String, Object> result = new HashMap<>();
        Map<String, String> header = new HashMap<>();
        header.put("appkey",salePartner.getSaleKey());
        header.put("appsecret",salePartner.getOther());
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(salePartner.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        String url = salePartner.getTwoOther()+"/"+artRecs.get(0).getOutid();
        HttpResponse execute = HttpRequest.put(url).header("appkey", salePartner.getSaleKey()).header("appsecret",salePartner.getOther()).body(JSONObject.toJSONString(params)).execute();
        String body = execute.body();
        String response = body;
        log.info("麦淘编辑接口请求参数={}", JSONObject.toJSONString(params));
        log.info("麦淘编辑接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"200".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "编辑失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        return AjaxResult.success(result);
    }


    private Map<String, Object> params(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String type, SalePartner salePartner) {
        Map<String, Object> paramss = new HashMap<>();
        if(!type.equals("delete")) {
//            if(type.equals("update")){
//                ArtRec artRecreq = new ArtRec();
//                artRecreq.setConfig(salePartner.getId());
//                artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
//                List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
//                if(CollectionUtils.isEmpty(artRecs)){
//                    throw new GlobalException("当前账号未推送,不可编辑");
//                }
//                paramss.put("id",artRecs.get(0).getId());
//            }
            paramss.put("status", 1);
            paramss.put("type", 1);
        }else{
            paramss.put("status", 2);
            paramss.put("type", 3);
        }
        paramss.put("descript","【"+descTitle+"_"+goodsInfoAndAttrValueDto.getId()+"】"+goodsInfoAndAttrValueDto.getDes());
        paramss.put("title", "【"+descTitle+"_"+goodsInfoAndAttrValueDto.getId()+"】"+goodsInfoAndAttrValueDto.getDes());
        BigDecimal bigDecimal = commonApi.addPrice(goodsInfoAndAttrValueDto.getPrice(), salePartner.getSeleep());
        commonApi.setPrice(bigDecimal,goodsInfoAndAttrValueDto.getId(),salePartner);
        paramss.put("price", bigDecimal.stripTrailingZeros().toPlainString());
        paramss.put("is_recommend", 1);
        paramss.put("main_pic", goodsInfoAndAttrValueDto.getTitleImg()==null?LCConstant.defaultImg:goodsInfoAndAttrValueDto.getTitleImg());
        GoodsInfoImg goodsInfoImg = new GoodsInfoImg();
        goodsInfoImg.setGoodsId(goodsInfoAndAttrValueDto.getId());
        goodsInfoImg.setType(Constants.STR_1);
        List<GoodsInfoImg> infoImgs = goodsInfoImgMapper.selectGoodsInfoImgList(goodsInfoImg);
        if(CollectionUtils.isNotEmpty(infoImgs)) {
            paramss.put("carousel_pic", infoImgs.stream().map(i -> i.getImgUrl()).collect(Collectors.joining(",")));
            paramss.put("detail_pic",infoImgs.stream().map(i -> i.getImgUrl()).collect(Collectors.joining(",")));
        }else{
            paramss.put("carousel_pic", LCConstant.defaultImg);
            paramss.put("detail_pic",LCConstant.defaultImg);
        }

        Map<String, Object> params = new HashMap<>();
        if(goodsInfoAndAttrValueDto.getGameName().equals("王者荣耀")) {
            paramss.put("category_id", 10);
            String response = getGameInfo(10);
            String data = JSONObject.parseObject(response).getString("data");
            JSONArray jsonArray = JSONArray.parseArray(data);
            String regional = goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF5());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF9());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF10());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF11());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF15());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF20());
            List<GameAttribute> gameAttributesss = getGameAttributs(pfIds);
            for(Object o : jsonArray){
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("按系统")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if(regional.equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("实名情况")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF16()));
                    String fieldName = gameAttribute1.getFieldName();
                    if(fieldName.equals("已删实名")||fieldName.equals("包人脸")){
                        fieldName = "支持人脸包赔";
                    }
                    for(Object p : jsonArray1){
                        if(fieldName.equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("有无防沉迷")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if("无防沉迷".equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("诚心卖服务")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if("卖家未购买诚心卖服务".equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("荣耀典藏")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String rydc = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                rydc+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(rydc)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),rydc.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("星元皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String xypf = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                xypf+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(xypf)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),xypf.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("内测皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String ncpf = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                ncpf+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(ncpf)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),ncpf.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("年限皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String nxpf = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                nxpf+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(nxpf)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),nxpf.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("KPL限定")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String kplxd = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                kplxd+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(kplxd)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),kplxd.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("情人节限定")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String qrjxd = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                qrjxd+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(qrjxd)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),qrjxd.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("珍稀皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String zxpf = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                zxpf+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(zxpf)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),zxpf.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("83版西游记")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String xyj = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                xyj+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(xyj)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),xyj.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("FMVP皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String fmvp = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                fmvp+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(fmvp)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fmvp.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("传说皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String cspf = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                cspf+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(cspf)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),cspf.substring(1));
                    }
                }
            }
        }
        else if(goodsInfoAndAttrValueDto.getGameName().equals("穿越火线")){
            paramss.put("category_id", 18);
            String response = getGameInfo(18);
            String data = JSONObject.parseObject(response).getString("data");
            JSONArray jsonArray = JSONArray.parseArray(data);
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF13());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF14());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF15());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF16());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF17());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF18());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF19());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF20());
            List<GameAttribute> gameAttributesss = getGameAttributs(pfIds);
            for(Object o : jsonArray) {
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("按服务器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if(JSONObject.parseObject(p.toString()).getString("attr_name").equals(goodsInfoAndAttrValueDto.getServerName())){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("暴走生化")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("音效卡")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("挑战大师")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("热门皮肤")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("热门武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("英雄级武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("实名情况")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                    if(gameAttribute1.getFieldName().equals("无修改机会且实名不是本人")){
                        bzsh = "zhichirenlianbaopei";
                    }else if(gameAttribute1.getFieldName().contains("有修改机会")){
                        bzsh = "keercishiming";
                    }else{
                        bzsh = "bukeercishiming";
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh);
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("稀有套装")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("王者炫金武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    String bzsh = "";
                    for(GameAttribute gameAttribute1: gameAttributesss) {
                        for (Object p : jsonArray1) {
                            if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                bzsh+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                            }
                        }
                    }
                    if(StringUtils.isNotEmpty(bzsh)){
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),bzsh.substring(1));
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("是否可排位")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"kepaiwei");
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("角色")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF19())) {
                        List<GameAttribute> jsList = getGameAttributs(goodsInfoAndAttrValueDto.getF19());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String bzsh = "";
                        for (GameAttribute gameAttribute1 : jsList) {
                            for (Object p : jsonArray1) {
                                if (gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))) {
                                    bzsh += "," + JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if (StringUtils.isNotEmpty(bzsh)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), bzsh.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("段位")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                    for(Object p : jsonArray1){
                        if(gameAttribute1.getFieldName().replace("未定级","无").equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                            break;
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("战区")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if(goodsInfoAndAttrValueDto.getGroupName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                            break;
                        }
                    }
                }
            }
        }
        else if(goodsInfoAndAttrValueDto.getGameName().equals("原神")){
            paramss.put("category_id", 13);
            String response = getGameInfo(13);
            String data = JSONObject.parseObject(response).getString("data");
            JSONArray jsonArray = JSONArray.parseArray(data);
            for(Object o : jsonArray){
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("按邮箱")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                        String youxiang = "";
                        if (gameAttribute1.getFieldName().equals("未绑定邮箱")){
                            youxiang = "youxiangweibangding";
                        }else if (gameAttribute1.getFieldName().equals("普通Q邮(随游戏出售)")){
                            youxiang = "qqyouxiang";
                        }else if (gameAttribute1.getFieldName().equals("字母Q邮")){
                            youxiang = "zimuqyouxiang";
                        }else{
                            youxiang = "qitayouxiang";
                        }
                        params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),youxiang);
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("按区服")){
                    String qufu = "";
                    if(goodsInfoAndAttrValueDto.getCarrierName().equals("游戏官方")){
                        qufu = "mihoyofu";
                    }else if(goodsInfoAndAttrValueDto.getCarrierName().equals("哔哩哔哩")){
                        qufu = "bilibilifu";
                    }else{
                        qufu = "guojifu";
                    }
                    params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),qufu);
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("按主角")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())){
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                        if(gameAttribute1.getFieldName().equals("男主")){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"nanzhu");
                        }else{
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"nvzhu");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("精二武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String jtwo = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    jtwo+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(jtwo)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), jtwo.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("精三武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String jthree = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    jthree+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(jthree)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), jthree.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("精四武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String jfour = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    jfour+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(jfour)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), jfour.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("精五武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String jfive = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    jfive+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(jfive)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), jfive.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("一命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("二命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("三命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("四命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("五命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("满命角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("武器")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("角色")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> list = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String juese = "";
                        for(GameAttribute gameAttribute1 : list){
                            for(Object p : jsonArray1){
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    juese+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(juese)) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), juese.substring(1));
                        }
                    }
                }
            }
        }
        else if(goodsInfoAndAttrValueDto.getGameName().equals("和平精英")){
            paramss.put("category_id", 15);
            String response = getGameInfo(15);
            String data = JSONObject.parseObject(response).getString("data");
            JSONArray jsonArray = JSONArray.parseArray(data);
            String regional = goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
            for(Object o : jsonArray) {
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("诚心卖服务")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if("卖家未购买诚心卖服务".equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("稀有飞行器")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF3());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().replace("-","").contains(JSONObject.parseObject(p.toString()).getString("attr_name").replace("-",""))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("稀有载具")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF2());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            String zjName = gameAttribute1.getFieldName().replace("(","").replace(")","");
                            if(zjName.contains("路特斯EL紫色")){
                                zjName = "路特斯电光紫";
                            }else if(zjName.contains("阿斯顿马丁")){
                                zjName = zjName.replace("DB","");
                            }else if(zjName.contains("兰博轿车金色")){
                                zjName = "兰博基尼Estoque炫光金";
                            }else if(zjName.contains("兰博轿车尊享铂")){
                                zjName = "兰博基尼Estoque尊享铂";
                            }else if(zjName.contains("兰博SVJ尊享铂")){
                                zjName = "兰博基尼AventadorSVJ尊享铂";
                            }else if(zjName.contains("兰博SUV金色")){
                                zjName = "兰博基尼URUS炫光金";
                            }else if(zjName.contains("兰博SUV尊享铂")){
                                zjName = "兰博基尼URUS尊享铂";
                            }else if(zjName.contains("特斯拉3紫色")){
                                zjName = "ModelⅢ（紫色）";
                            }else if(zjName.contains("特斯拉X紫色")){
                                zjName = "ModelX（紫色）";
                            }else if(zjName.contains("兰博轿车灰色")){
                                zjName = "兰博基尼Estoque银翼灰";
                            }else if(zjName.contains("兰博SVJ绿色")){
                                zjName = "兰博基尼AventadorSVJ翡翠绿";
                            }else if(zjName.contains("兰博SUV黄色")){
                                zjName = "兰博基尼URUS明艳黄";
                            }else if(zjName.contains("特斯拉3白色")){
                                zjName = "ModelⅢ（白色）";
                            }else if(zjName.contains("特斯拉3银色")){
                                zjName = "ModelⅢ（银色）";
                            }else if(zjName.contains("特斯拉X白色")){
                                zjName = "ModelX（白色）";
                            }else if(zjName.contains("特斯拉X银色")){
                                zjName = "ModelX（银色）";
                            }else if(zjName.contains("路特斯EL灰色")){
                                zjName = "路特斯冰川灰";
                            }else if(zjName.contains("塞莎")){
                                zjName = zjName.replace("塞莎","塞莎KL");
                            }else if(zjName.contains("空客恋语之翼僚机")){
                                zjName = zjName.replace("空客","空客HL");
                            }else if(zjName.contains("玛莎拉蒂M白色")){
                                zjName = "玛莎拉蒂MC20（星石白）";
                            }else if(zjName.contains("玛莎拉蒂G绿色")){
                                zjName = "玛莎拉蒂Grecale（薄荷绿）";
                            }
                            for (Object p : jsonArray1) {
                                String name = JSONObject.parseObject(o.toString()).getString("attr_name").replace("（","").replace("）","").replace(" ","");
                                if(name.contains("特斯拉Roadster")){
                                    name = name.replace("oadster","");
                                }else if(name.contains("特斯拉Cybertuck")){
                                    name = name.replace("ybertuck","");
                                }
                                if(zjName.contains(name)){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("优质套装")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF5());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(JSONObject.parseObject(p.toString()).getString("attr_name").contains(gameAttribute1.getFieldName())){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("稀有套装")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF5());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(JSONObject.parseObject(p.toString()).getString("attr_name").contains(gameAttribute1.getFieldName())){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("优质枪皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF1());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(JSONObject.parseObject(p.toString()).getString("attr_name").contains(gameAttribute1.getFieldName())){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("attr_name").equals("按大区")) {
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for (Object p : jsonArray1) {
                        if (regional.equals(JSONObject.parseObject(p.toString()).getString("attr_name"))) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("attr_name").equals("实名情况")) {
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())){
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        for (Object p : jsonArray1) {
                            if (gameAttribute1.getFieldName().replace("包人脸","支持人脸包赔").replace("已删实名","可二次实名").equals(JSONObject.parseObject(p.toString()).getString("attr_name"))) {
                                params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), JSONObject.parseObject(p.toString()).getString("attr_value"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("有无防沉迷")){
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for(Object p : jsonArray1){
                        if("无防沉迷".equals(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
            }
        }
        else if(goodsInfoAndAttrValueDto.getGameName().equals("枪战王者")){
            paramss.put("category_id", 20);
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF7());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF8());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF11());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF13());
            List<GameAttribute> gameAttributesss = getGameAttributs(pfIds);
            String response = getGameInfo(15);
            String data = JSONObject.parseObject(response).getString("data");
            JSONArray jsonArray = JSONArray.parseArray(data);
            String regional = goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
            for(Object o : jsonArray) {
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("万化皮肤")){
                    if(CollectionUtils.isNotEmpty(gameAttributesss)){
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributesss) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("实名情况")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())){
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
                        if(gameAttribute1.getFieldName().contains("有修改人脸机会")){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"keercishiming");
                        }else if(gameAttribute1.getFieldName().equals("无修改人脸机会/实名不是本人")){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"bukeercishiming");
                        }else if(gameAttribute1.getFieldName().equals("无修改人脸机会/实名是本人")){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"zhichirenlianbaopei");
                        }else{
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),"keercishiming");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("角色")){
                    if(CollectionUtils.isNotEmpty(gameAttributesss)){
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributesss) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("王者系列")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("热门武器")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF7())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF7());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().contains(onlyHanZi(JSONObject.parseObject(p.toString()).getString("attr_name")))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("attr_name").equals("至尊系列")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())){
                        List<GameAttribute> gameAttributeList = getGameAttributs(goodsInfoAndAttrValueDto.getF12());
                        JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                        String fxq = "";
                        for(GameAttribute gameAttribute1: gameAttributeList) {
                            for (Object p : jsonArray1) {
                                if(gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("attr_name"))){
                                    fxq+=","+JSONObject.parseObject(p.toString()).getString("attr_value");
                                }
                            }
                        }
                        if(StringUtils.isNotEmpty(fxq)){
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"),fxq.substring(1));
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("attr_name").equals("操作系统")) {
                    JSONArray jsonArray1 = JSONArray.parseArray(JSONObject.parseObject(o.toString()).getString("_child"));
                    for (Object p : jsonArray1) {
                        if (regional.equals(JSONObject.parseObject(p.toString()).getString("attr_name"))) {
                            params.put(JSONObject.parseObject(o.toString()).getString("attr_value"), JSONObject.parseObject(p.toString()).getString("attr_value"));
                        }
                    }
                }
            }
        }
        paramss.put("form",params);
        return paramss;
    }

    //只保留中文
    private String onlyHanZi(String str) {
        String reg = "[^\u4e00-\u9fa5]";
        str = str.replaceAll(reg, "");
        return str;
    }

    private List<GameAttribute> getGameAttributs(String ids) {
        List<GameAttribute> list = new ArrayList<>();
        if (StringUtils.isNotEmpty(ids)) {
            list = gameAttributeMapper.selectGameAttributeListByIds((Long[]) ConvertUtils.convert(ids.split(","),
                    Long.class));
        }
        return list;
    }

    private String reIds(String allIds, String ids) {
        if (StringUtils.isNotEmpty(ids)) {
            if (StringUtils.isNotEmpty(allIds)) {
                allIds = allIds + "," + ids;
            } else {
                allIds = ids;
            }
        }
        return allIds;
    }

    @Override
    public AjaxResult delGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, "delete", salePartner);
        Map<String, Object> result = new HashMap<>();
        Map<String, String> header = new HashMap<>();
        header.put("appkey",salePartner.getSaleKey());
        header.put("appsecret",salePartner.getOther());
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(salePartner.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        String url = salePartner.getTwoOther()+"/"+artRecs.get(0).getOutid();
        HttpResponse execute = HttpRequest.put(url).header("appkey", salePartner.getSaleKey()).header("appsecret",salePartner.getOther()).body(JSONObject.toJSONString(params)).execute();
        String body = execute.body();
        String response = body;
        log.info("麦淘删除接口请求参数={}", JSONObject.toJSONString(params));
        log.info("麦淘删除接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!Objects.isNull(resultJson)) {
            if (!"200".equals(resultJson.getString("code"))) {
                result.put("code", 500);
            } else {
                result.put("code", 200);
            }
            result.put("msg", resultJson.getString("msg"));
        } else {
            result.put("code", 500);
            result.put("msg", "删除失败");
        }
        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);

        return AjaxResult.success(result);
    }

    public static void main(String[] args) {

        String response = getGames();
        System.out.println(response);
    }
    public static String getGames() {
        Map<String, String> header = new TreeMap<>();
        header.put("appkey","baixing");
        header.put("appsecret","9BEEFE37EDF78027AC1FE6DD832FE993");
        String response = HttpUtil.doGet("https://sys.api.paoyang.com/openapi/category/list",null,header);
        return response;
    }

    public static String getGameInfo(int id) {
        Map<String, String> header = new TreeMap<>();
        header.put("appkey","baixing");
        header.put("appsecret","9BEEFE37EDF78027AC1FE6DD832FE993");
        String response = HttpUtil.doGet("https://sys.api.paoyang.com/openapi/attr/list/"+id,null,header);
        return response;
    }

}
